package com.atstudy.convert;

import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2023/2/15 15:18
 * @copyright: 博为峰
 */
public class StringToDate implements Converter<String, Date> {
    @Override
    public Date convert(String source) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date date = null;
        try {
            date = format.parse(source);
        } catch (ParseException e) {
            throw new RuntimeException("类型转换出错");
        }
        return date;
    }
}
